$(function () {
    //抽取js变量
    var claimsClientDetails_datagrid = $("#claimsClientDetails_datagrid");
    var salary_dialog = $("#salary_dialog");
    var dialog2 = $("#dialog2");
    var claimsClientDetails_form = $("#claimsClientDetails_form");
    var form2 = $("#form2");
    $("#box").on('click', 'a.my_btn', function () {
        var index = $(this).data("index");
        var rows = claimsClientDetails_datagrid.datagrid("getRows");
        var row = rows[index];
        salary_dialog.dialog("open");

        row["brand"] = row.car.brand;
        row["productName"] = row.car.productName;
        row["displacement"] = row.car.displacement;
        row["evaluation"] = row.car.evaluation;
        row["type"] = row.car.type;
        row["size"] = row.car.size;

        claimsClientDetails_form.form("load", row);
    }).on('click', 'a.my_btn2', function () {
        var index = $(this).data("index");
        var rows = claimsClientDetails_datagrid.datagrid("getRows");
        var row = rows[index];
        dialog2.dialog("open");

        row["sn"] = row.insureInfo.sn;
        row["applyDate"] = row.insureInfo.applyDate;
        row["auditDate"] = row.insureInfo.auditDate;
        row["beginDate"] = row.insureInfo.beginDate;
        row["endDate"] = row.insureInfo.endDate;


        row["totalAmount"] = row.insureInfo.totalAmount;

        row["payMethod"] = row.insureInfo.payMethod;
        form2.form("load", row);
    })


    claimsClientDetails_datagrid.datagrid({
        url: '/claimsClientDetails/query.do',
        fitColumns: true,
        fit: true,//自动填充
        toolbar: '#claimsClientDetails_toolbar',
        pagination: true, //在DataGrid控件底部显示分页工具栏
        rownumbers: true, //显示一个行号列。
        singleSelect: true,//只允许选择一行
        striped: true, //显示斑马线效果
        columns: [[
            {field: 'id', checkbox: true},
            {
                field: 'client', title: '客户姓名', width: 80, formatter: function (value, row, index) {
                    return value.name;
                }
            },
            {
                field: 'client1', title: '性别', width: 80, formatter: function (value, row, index) {
                    if (row.client.gender) {
                        return "男";
                    } else {
                        return "女";
                    }
                }
            },

            {
                field: 'client2', title: '工作', width: 80, formatter: function (value, row, index) {
                    return row.client.job;
                }
            },
            {
                field: 'client3', title: '电话', width: 80, formatter: function (value, row, index) {
                    return row.client.tel;
                }
            },
            {
                field: 'client4', title: '邮箱', width: 80, formatter: function (value, row, index) {
                    return row.client.email;
                }
            },
            {
                field: 'client5', title: 'QQ', width: 80, formatter: function (value, row, index) {
                    return row.client.qq;
                }
            },

            {
                field: 'car', title: '汽车信息', width: 80, formatter: function (value, row, index) {
                    return "<a href='javascript:' data-index='" + index + "' class='easyui-linkbutton my_btn'>查看</a>";
                }
            },
            {
                field: 'insureInfo', title: '保险单明细', width: 80, formatter: function (value, row, index) {
                    return "<a href='javascript:' data-index='" + index + "' class='easyui-linkbutton my_btn2'>查看</a>";
                }
            }
            // {
            //     field: 'button', title: '查看薪资明细', width: 80, formatter: function (value, row, index) {
            //
            //     }
            // }

        ]]
    });

    $("#claimsClientDetails_toolbar a").click(function () {
        var keyword1 = $("#keyword").textbox('getValue');


        claimsClientDetails_datagrid.datagrid('load', {
            keyword: keyword1
        });
    })

    salary_dialog.dialog({
        title: "车辆信息",
        width: 250,
        height: 280,
        top: 100,
        closed: true,
        // onClose: function () {
        //     claimsClientDetails_form.form('clear');
        // }
    });

    dialog2.dialog({
        title: "保险单明细",
        width: 300,
        height: 350,
        top: 100,
        closed: true,
        // onClose: function () {
        //     form2.form('clear');
        // }
    });


});










